package frontend.visitor.symboltbl.scope;

import ir.values.FunctionIr;

import java.util.HashMap;
import java.util.Map;

public class RootScope extends Scope {

    @Override
    public String getIndividualName() {
        return "";
    }

    private final Map<String, FunctionIr> functionSymbolMap = new HashMap<>();
    @Override
    public boolean duplicateCheck(String ident) {
        return super.duplicateCheck(ident) && !functionSymbolMap.containsKey(ident);
    }

    public boolean putFunctionSymbol(String ident, FunctionIr functionIr) {
        if (!duplicateCheck(ident)) {
            return false;
        }
        functionSymbolMap.put(ident, functionIr);
        return true;
    }
    public FunctionIr findFunctionSymbol(String ident) {
        return functionSymbolMap.get(ident);
    }
}
